package com.qianfeng.zhangwei.day30_bdmap;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.qianfeng.zhangwei.day30_bdmap.base.BaseMapActivity;
import com.qianfeng.zhangwei.day30_bdmap.base.FmMapActivity;
import com.qianfeng.zhangwei.day30_bdmap.location.LocationActivity;
import com.qianfeng.zhangwei.day30_bdmap.overlay.OverlayActivity;
import com.qianfeng.zhangwei.day30_bdmap.search.SearchActivity;
import com.qianfeng.zhangwei.day30_bdmap.utils.LocationHelper;

public class MainActivity extends AppCompatActivity  implements View.OnClickListener{

    private Button baseBtn, overlayBtn, searchBtn, locationBtn, fmMapBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        baseBtn = (Button) this.findViewById(R.id.base_btn);
        overlayBtn = (Button) this.findViewById(R.id.overlay_btn);
        searchBtn = (Button) this.findViewById(R.id.search_btn);
        locationBtn = (Button) this.findViewById(R.id.location_btn);
        fmMapBtn = (Button) this.findViewById(R.id.fragmt_map_btn);
        baseBtn.setOnClickListener(this);
        overlayBtn.setOnClickListener(this);
        searchBtn.setOnClickListener(this);
        locationBtn.setOnClickListener(this);
        fmMapBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            case R.id.base_btn:
                intent.setClass(this, BaseMapActivity.class);
                break;
            case R.id.fragmt_map_btn:
                intent.setClass(this, FmMapActivity.class);
                break;
            case R.id.overlay_btn:
                intent.setClass(this, OverlayActivity.class);
                break;
            case R.id.search_btn:
                intent.setClass(this, SearchActivity.class);
                break;
            case R.id.location_btn:
                intent.setClass(this, LocationActivity.class);
                break;
        }
        startActivity(intent);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        LocationHelper.getInstance().stop();
    }
}